package database;

import java.sql.Connection;
import java.sql.DriverManager;

public class DbManager {
// Connexion à la base
	public Connection Open_ConnectDB() {
		String connectionURL = "jdbc:mysql://localhost:3306/Gestion_article";
		String NomDB = "Gestion_article";
		String driver = "com.mysql.jdbc.Driver";
		String userName = "root";
		String password = "root";
		Connection connection = null;
		try {
			Class.forName(driver).newInstance();
			connection = DriverManager.getConnection(connectionURL,
					userName, password);
                        System.err.println ("Correcte connexion !") ;
		} catch (Exception ex) {
			System.err.println ("[PANIC] Erreur de connexion au serveur de Base de données !") ;
			ex.printStackTrace();
		}
		return connection;
	}
// Deconnexion de la base
	public void Close_ConnectDB(Connection conn) {
		if (conn != null) {
			try {
				conn.close();
			} catch (Exception ex) {
			}
		}
	}
}